package com.xveshe.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xveshe.common.annotation.Log;
import com.xveshe.common.core.controller.BaseController;
import com.xveshe.common.core.domain.AjaxResult;
import com.xveshe.common.enums.BusinessType;
import com.xveshe.admin.domain.XsglGxsj;
import com.xveshe.admin.service.IXsglGxsjService;
import com.xveshe.common.utils.poi.ExcelUtil;
import com.xveshe.common.core.page.TableDataInfo;

/**
 * 岗训时间Controller
 *
 * @author geyasong
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/admin/gxsj")
public class XsglGxsjController extends BaseController
{
    @Autowired
    private IXsglGxsjService xsglGxsjService;

    /**
     * 查询岗训时间列表
     */
    @GetMapping("/list")
    public TableDataInfo list(XsglGxsj xsglGxsj)
    {
        startPage();
        List<XsglGxsj> list = xsglGxsjService.selectXsglGxsjList(xsglGxsj);
        return getDataTable(list);
    }

    /**
     * 导出岗训时间列表
     */
    @PreAuthorize("@ss.hasPermi('admin:gxsj:export')")
    @Log(title = "岗训时间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XsglGxsj xsglGxsj)
    {
        List<XsglGxsj> list = xsglGxsjService.selectXsglGxsjList(xsglGxsj);
        ExcelUtil<XsglGxsj> util = new ExcelUtil<XsglGxsj>(XsglGxsj.class);
        util.exportExcel(response, list, "岗训时间数据");
    }

    /**
     * 获取岗训时间详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(xsglGxsjService.selectXsglGxsjById(id));
    }

    /**
     * 新增岗训时间
     */
    @PreAuthorize("@ss.hasPermi('admin:gxsj:add')")
    @Log(title = "岗训时间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XsglGxsj xsglGxsj)
    {
        return toAjax(xsglGxsjService.insertXsglGxsj(xsglGxsj));
    }

    /**
     * 修改岗训时间
     */
    @PreAuthorize("@ss.hasPermi('admin:gxsj:edit')")
    @Log(title = "岗训时间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XsglGxsj xsglGxsj)
    {
        return toAjax(xsglGxsjService.updateXsglGxsj(xsglGxsj));
    }

    /**
     * 删除岗训时间
     */
    @PreAuthorize("@ss.hasPermi('admin:gxsj:remove')")
    @Log(title = "岗训时间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(xsglGxsjService.deleteXsglGxsjByIds(ids));
    }
}
